const imageAsync = (url) => {
    return new Promise((resolve, reject) => {
        const img = new Image()
        img.src = url
        img.onload = () => {
            resolve('加载成功')
        }
        img.onerror = () => {
            reject('加载失败')
        }
    })
}

imageAsync('img').then(res => console.log(res), err => console.log(err))